package edu.sandau.b230151.b23015135.mapper;

import edu.sandau.b230151.b23015135.model.Book;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface BookMapper {


//    @Select("select * from book")
    public List<Book> findAll(Book book);

    @Delete("delete from book where id = #{id}")
    public void deleteById(String id);

    @Insert("insert into book(id,name,author) values(#{book.id},#{book.name},#{book.author})")
    public void save(@Param("book") Book book);

    @Update("update book set name = #{book.name},author = #{book.author} where id = #{book.id}")
    public void update(@Param("book") Book book);

    @Select("select * from book where id = #{id}")
    public Book getReferenceById(String id);

    @Select("select * from book where name like #{book.name} or author = #{book.author}")
    List<Book> search(@Param("book") Book book);
}
